<template>
  <div class="page has-navbar" v-nav="{title: '编辑员工', showBackButton: true}">
    <div class="page-content padding-top">
        <item class="y-item">
          <span class="item-title">姓名</span>
          <input type="text" class="y-item-input" name="" v-model="staffInfo.userName" placeholder="请输入姓名" required>
        </item>
        <item class="y-item" style="margin-bottom:50px;">
          <span class="item-title">手机号</span>
          <input type="tel" class="y-item-input" name="" v-model="staffInfo.userMobile" placeholder="请输入手机号" required>
        </item>
        <div class="outbtn" ><md-button class="button button-assertive button-block" @click.native="save">保存</md-button></div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      staffInfo:{
        userName:'',
        userMobile:''
      }
    }
  },
  created(){
    var _this = this;
    axios.get(baseUrl+'/controller/getUserList',{params:{
        marketId:sess.get('userSession').marketId,
        shopId:sess.get('userSession').shopId,
        userId:this.$route.params.id
      }
    })
    .then(function(res){
      _this.staffInfo = res.data.result[0]
    })
  },
  methods:{
    save() {
      var _this = this;
      axios.get(baseUrl+'/controller/updateUser',{params:{
          userName:_this.staffInfo.userName,
          userMobile:_this.staffInfo.userMobile,
          userId:this.$route.params.id
        }
      })
      .then(function(res){
        $router.back('/staff')
      })

    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
